<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>仓库统计</title>
    <link rel="stylesheet" href="css/table.css">
    <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="js/timeformat.js"></script>
</head>
<body>
<div>
   <select id="Myselect">
       <option value=0>请选择查询类型</option>
       <option value=1>入库</option>
       <option value=2>出库</option>
   </select>
    <input style="border-radius:6px;"  type="button"    id="btn1" value="搜索" />
</div>

<div id="content"></div>
</body>
<script>
       $(document).ready(function(){
        $("#btn1").click(function(){
            query();
        });
    });

    function details(warehouseId) {

        location.href="http://localhost:8080/userCore/go_to_warehouse_statistics_details?warehouseId="+warehouseId;
    }

    query();
    function query() {
        var myselect=document.getElementById("Myselect").value;

        $.ajax({
            url :   "warehouse/getwarehousebystate",
            type:   "post",
            data:JSON.stringify({
                state : myselect,
            }),
            beforeSend: function(request) {
                request.setRequestHeader("token", "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwiaWF0IjoxNTMyNDA4ODMzLCJzdWIiOiIxLHd6eSwwIiwiZXhwIjoxNTMyNDE2MDMzfQ.DEpHIrk2X8U4Un_SdDNiqqPPEYHXX6DYfx_prQ3QIZQ");
            },
            contentType:"application/json;",
            success:function(data){
                goToLogin(data);
                console.log(data);
                if(data==null||data==""||data==undefined){
                    $("#content").html("暂无数据");
                }else{
                    var content='<table class="bordered" cellspacing="0" border="0"> <thead>\n' +
                        '\n' +
                        '        <tr>\n' +
                        '            <th>项目名称</th>\n' +
                        '            <th>材料备注</th>\n' +
                        '            <th>操作/申请时间</th>\n' +
                        '            <th>操作</th>\n' +
                        '        </tr>  ';
                    var list = data.data;
                    for(var i=0;i<list.length;i++){
                        var obj=list[i];

                        content+='<tr>' +
                            '<th>'+obj.projectName+'</th>' +
                            '<th>'+obj.materialDesc+'</th>' +
                            '<th>'+formatDateTime(obj.oprDate)+'</th>' +
                            '<th><a href="javascript:;" onclick="details('+obj.warehouseId+')">详情</a></th>' +
                            '<tr/>';
                    }
                    content+='</thead>\n' +
                        '        <tbody id="tbody_$commonName$"></tbody>\n' +
                        '    </table>';

                    console.log(content);
                    $("#content").html(content);
                }

            }
        });
    }
</script>
</html>